package sdb

import (
	"os"
	"xml"
	"strings"
	"goaws.googlecode.com/hg/aws"
)

type errorResponse struct {
	XMLName xml.Name "Response"
	Errors  []struct {
		Code, Message string
	} "Error"
}

func (e *errorResponse) String() string {
	errors := make([]string, 0, len(e.Errors))
	for _, err := range e.Errors {
		errors = append(errors, err.Code+": "+err.Message)
	}
	return strings.Join(errors, ", ")
}

func newErrorResponse() os.Error { return new(errorResponse) }

type listDomainsResponse struct {
	XMLName     xml.Name "ListDomainsResponse"
	DomainNames []string "ListDomainsResult>DomainName"
	NextToken   string   "ListDomainsResult>NextToken"
}

type DomainMetadata struct {
	Timestamp                int64
	ItemCount                int
	AttributeValueCount      int
	AttributeNameCount       int
	ItemNamesSizeBytes       int64
	AttributeValuesSizeBytes int64
	AttributeNamesSizeBytes  int64
}

type domainMetadataResponse struct {
	XMLName              xml.Name "DomainMetadataResponse"
	DomainMetadataResult *DomainMetadata
}

type selectResponse struct {
	XMLName   xml.Name "SelectResponse"
	Items     []Item   "SelectResult>Item"
	NextToken string   "SelectResult>NextToken"
}

type getAttributesResponse struct {
	XMLName    xml.Name          "GetAttributesResponse"
	Attributes aws.AttributeList "GetAttributesResult>Attribute"
}
